package com.kingyun.gpsinspection.purificationservice.common.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Created by yangcs on 2016/11/21.
 */
public class BootstrapUtil {

    public static Map filterStringToMap(String filter){
        Map map = new HashMap<>();
        if(StringUtils.isNotBlank(filter)){
            JSONObject jsonObject = JSON.parseObject(filter);
            for (String str: jsonObject.keySet()) {
                map.put(str, jsonObject.get(str));
            }
        }
        return map;
    }

    /**
     * 生成6位验证码
     * @return
     */
    public static String getAuthCode(){
        Random rad=new Random();
        String result  = rad.nextInt(1000000) +"";
        if(result.length()!=6){
            return getAuthCode();
        }
        return result;
    }
}
